package cn.chenhuanming.shh.administer.intermediary.business.eventHandler;

import cn.chenhuanming.shh.administer.entity.jpa.House;
import cn.chenhuanming.shh.administer.intermediary.business.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.core.annotation.HandleBeforeCreate;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;

/**
 * Created by chenhuanming on 2017-07-31.
 *
 * @author chenhuanming
 */
@Component
@RepositoryEventHandler
public class HouseEventHandler {

    @Autowired
    HouseService houseService;

    @PreAuthorize("hasRole('SHOP_BROKER')")
    @HandleBeforeCreate
    public void beforeCreate(House house){
       houseService.beforeCreate(house);
    }

//    @HandleBeforeSave
//    public void beforeSave(House house) {
//
//    }
}
